Hello and welcome to this lecture.
In this lecture we'll be creating event listeners and handlings the event listeners will listen out
for Wayne the key up button or keyboard hero is suppressed or when the key down button or hour is press
the event listeners will listen up for that.
Once they pick that up it pass that information to the event handler.
They'll actually fire up the code to respond to those presses those key presses.
So let's go ahead and create the event listeners and handlers are right.
This is the javascript so far.
We're going to create the event listener just underneath the variables where the variables are so to
create these event handlers an event listeners will respond to the activity of the paddle.
So when there is the key are pressed all the key down to suppress these activities will relate to the
paddle so to create event listener will type in document dot add event listener So b.
All right so document dot add event list.
Notice the camel case here.
Lower case upper case and then upper case or 8 and then we need to pass it a couple of parameters.
So put the parent this is there and the first value week on past this hour.
Event listener is the text key down.
All in lower case.
And then the next value when it's a pass is the actual event handler that will handle the event so call
it
key down.
Glad.
Notice there's no quotes around it.
All saw it's come well case.
Comma.
Now we have to give you the value of starting value and the value will be false.
It's a boolean value.
Falls means bad when the keys are not pressed.
There is no activity hansis set to force.
So a semicolon there to end that.
Next we going to create an event listener to listen for the key up when the key when the key button
hole keyboard arrow is pressed with the listener for that sort of module.
I'll just copy this code here and drop it pasted and just change a few values.
So all I need to change here is this to harp.
So when the key a button is pressed change that to upswell.
No it is so come or case and the value is a boolean value salthill force when there is no activity.
So at the moment there is some activity when that when the key are button or is pressed on the keyed
button on our espress that indicates some activities and this value is no longer false.
So who's on the force when there is no action or does not.
None of the keys are pressed.
All right now that we have created the event handler and listener in their necks lecture we will create
the function that is the activity that will happen once the key of Paul key down has been press.
We need to create a function to actually respond and do something to that key press so we'll do that
in the next lecture.
Thank you so much for it.
Bye for now.